package org.dizem.minichat.util;

import craky.util.SwingResourceManager;
import org.dizem.minichat.Constants;

import javax.swing.*;
import java.awt.*;

/**
 * User: DIZEM
 * Time: 11-3-26 上午10:17
 */
public class ImageUtil {
	public static Image getImage(String name) {
		return SwingResourceManager.getImage(Constants.IMAGE_DIR + Constants.FILE_SEP + name);
	}

	public static Image getImage(String name, boolean createdByIcon) {
		if (createdByIcon) {
			return new ImageIcon(Constants.IMAGE_DIR + Constants.FILE_SEP + name).getImage();
		} else {
			return getImage(name);
		}
	}

	public static Icon getIcon(String name) {
		return SwingResourceManager.getIcon(Constants.IMAGE_DIR + Constants.FILE_SEP + name);
	}

	public static Icon getIcon(String name, boolean createdByIcon) {
		if (createdByIcon) {
			return new ImageIcon(Constants.IMAGE_DIR + Constants.FILE_SEP + name);
		} else {
			return getIcon(name);
		}
	}
}
